{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "89d60cf6-70cc-4dba-90d0-d7398574ec0a",
   "metadata": {},
   "source": [
    "### Try this notebook in Google Colab, Binder or SageMaker!\n",
    "\n",
    "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/PyVista/UniformGrid.ipynb)\n",
    "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/HEAD?labpath=examples%2Fintegrations%2FPyVista%2FUniformGrid.ipynb)\n",
    "[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github.com/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/PyVista/UniformGrid.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e04361ad-b0a3-4407-888d-779ae6f1863d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Install dependencies for this example\n",
    "import sys\n",
    "\n",
    "!{sys.executable} -m pip install -q pyvista \"itkwidgets[all]>=1.0a23\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8a45c57e-d319-4fd2-9251-567b1f918970",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyvista\n",
    "from pyvista import examples\n",
    "\n",
    "from itkwidgets import view"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9e67fcf6-99bd-4940-aaab-4fa28cbe1ea2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><th>Header</th><th>Data Arrays</th></tr><tr><td>\n",
       "<table>\n",
       "<tr><th>UniformGrid</th><th>Information</th></tr>\n",
       "<tr><td>N Cells</td><td>729</td></tr>\n",
       "<tr><td>N Points</td><td>1000</td></tr>\n",
       "<tr><td>X Bounds</td><td>0.000e+00, 9.000e+00</td></tr>\n",
       "<tr><td>Y Bounds</td><td>0.000e+00, 9.000e+00</td></tr>\n",
       "<tr><td>Z Bounds</td><td>0.000e+00, 9.000e+00</td></tr>\n",
       "<tr><td>Dimensions</td><td>10, 10, 10</td></tr>\n",
       "<tr><td>Spacing</td><td>1.000e+00, 1.000e+00, 1.000e+00</td></tr>\n",
       "<tr><td>N Arrays</td><td>2</td></tr>\n",
       "</table>\n",
       "\n",
       "</td><td>\n",
       "<table>\n",
       "<tr><th>Name</th><th>Field</th><th>Type</th><th>N Comp</th><th>Min</th><th>Max</th></tr>\n",
       "<tr><td><b>Spatial Point Data</b></td><td>Points</td><td>float64</td><td>1</td><td>0.000e+00</td><td>7.290e+02</td></tr>\n",
       "<tr><td>Spatial Cell Data</td><td>Cells</td><td>float64</td><td>1</td><td>0.000e+00</td><td>5.120e+02</td></tr>\n",
       "</table>\n",
       "\n",
       "</td></tr> </table>"
      ],
      "text/plain": [
       "UniformGrid (0x7f1ae6cec8e0)\n",
       "  N Cells:\t729\n",
       "  N Points:\t1000\n",
       "  X Bounds:\t0.000e+00, 9.000e+00\n",
       "  Y Bounds:\t0.000e+00, 9.000e+00\n",
       "  Z Bounds:\t0.000e+00, 9.000e+00\n",
       "  Dimensions:\t10, 10, 10\n",
       "  Spacing:\t1.000e+00, 1.000e+00, 1.000e+00\n",
       "  N Arrays:\t2"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset = examples.load_uniform()\n",
    "dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "70e42aaf-6d75-4bb3-8e50-20e735ba98ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "                <img id=screenshot_imjoy_window_71adfe38-0e1f-4546-a178-8a72868f509e src=>\n",
       "                <script id=\"script_imjoy_window_71adfe38-0e1f-4546-a178-8a72868f509e\" type=\"text/javascript\">\n",
       "                    var container = document.getElementById(\"script_imjoy_window_71adfe38-0e1f-4546-a178-8a72868f509e\").parentNode;\n",
       "                    var image = document.getElementById(\"screenshot_imjoy_window_71adfe38-0e1f-4546-a178-8a72868f509e\");\n",
       "                    if (!image) {\n",
       "                        image = document.createElement(\"img\");\n",
       "                        image.id = \"screenshot_imjoy_window_71adfe38-0e1f-4546-a178-8a72868f509e\";\n",
       "                        container.appendChild(image);\n",
       "                    }\n",
       "                    image.src = \"\";\n",
       "                    var viewer = document.getElementById(\"imjoy_window_71adfe38-0e1f-4546-a178-8a72868f509e\");\n",
       "                    // Hide the static image if the Viewer is visible\n",
       "                    image.style.display = viewer ? \"none\" : \"block\";\n",
       "                </script>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "window.connectPlugin && window.connectPlugin(\"45aefd3e-4e2f-4e90-8ef0-00db06f18934\")"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div id=\"e60c7147-c292-4085-b4c7-d11bc956ccc3\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<itkwidgets.viewer.Viewer at 0x7f1ae6cb4250>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view(dataset)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3418ace0-0c70-42aa-b3c0-8a68a100c87a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
